package ai.fabu.dataplatform.bean.task;

import ai.fabu.dataplatform.utils.TimeUtil;
import lombok.Data;
import lombok.Setter;
import lombok.Value;
import lombok.experimental.NonFinal;
import org.bson.types.ObjectId;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

import java.util.HashMap;
import java.util.Map;

import static ai.fabu.dataplatform.constant.ConstantName.*;
import static ai.fabu.dataplatform.constant.ConstantValue.PROCESS_NOT_START_STATUS;
import static ai.fabu.dataplatform.constant.ConstantValue.STRING_DEFAULT;

@Value
@Document(collection = "group_task")
public class GroupDataTask {
    public static GroupDataTask staticGroupDataTask(String groupName, String groupPath, String mapName, String vehicleName, byte completeStatus, String uploader){
        return new GroupDataTask(null, groupName, groupPath, mapName, vehicleName, completeStatus, UN_SET, new HashMap<>(), 0, 0, STRING_DEFAULT, uploader, TimeUtil.getNowTimestampLong(), TimeUtil.getNowTimestampLong());
    }

    @NonFinal
    @Setter
    @Id
    ObjectId id;
    @Field(GROUP_NAME)
    String groupName;
    @Field(GROUP_PATH)
    String groupPath;
    @Field(MAP_NAME)
    String mapName;
    @Field(VEHICLE_NAME)
    String vehicleName;
    /**
     * 0 未开始 1 进行中 2 已完成 3 失败
     */
    @Field(COMPLETE_STATUS)
    Byte completeStatus;
    /**
     * 访问源，地址加端口的字符串
     */
    String source;
    Map<String, byte[]> metadata;
    @Field(DONE_BAG_NUM)
    Integer doneBagNum;
    @Field(TOTAL_BAG_NUM)
    Integer totalBagNum;
    @Field(CURRENT_BAG_NAME)
    String currentBagName;
    @Field(UPLOADER)
    String uploader;
    @Field(CREATE_TIME)
    Long createTime;
    @Field(UPDATE_TIME)
    Long updateTime;
}
